< previous page page_472 next page >

Page 472
vbDirectory returns only the subdirectories (or folders) in the specified path. The constant vbVolume causes Dir$ to return the specified drive's volume label. The available constants are summarized in Table 21.1. (You also can display a list of folders with a directory list box.)
Table 21.1 Constants Control the Behavior of the Dir$ Function
ConstantValuePurpose
vbNormal0(Default value)
vbHidden2Include hidden files
vbSystem4Include system files
vbVolume8Return drive volume label
vbDirectory16Display subdirectories
vbReadOnly1Include read-only files

note.gif Constants can be added together if you want to use more than one. For example, the following code finds the system, hidden, and read-only file IO.SYS on a Windows 95 machine:
Debug.Print Dir$("C:\IO.SYS",vbHidden+vbSystem+vbReadOnly) square.gif

Note that the vbHidden constant refers to a file's attributes and not the Windows Explorer option that hides certain file types. You can view the attributes of a file by right-clicking the file's name and choosing Properties, as depicted in Figure 21.1, or by using the MS-DOS ATTRIB command.
0472-01.jpg
Figure 21.1
File attributes, shown in the Windows
Explorer, can determine whether the
Dir$ function returns a specific filename.

 
< previous page page_472 next page >